const express = require("express")
const mysql = require("mysql")
//multer上传文件
const multer = require("multer")
const router = express.Router()
const fs = require("fs")
const controller = require('../controller/controller.js')
const { connection } = require("../model/model.js")


// 登录页面
router.get('/', controller.loginpage)
// 登录操作
router.post('/login', controller.login)
// 退出登录
router.get('/loginOut', controller.loginOut)

router.get('/registerPage', controller.registerPage)

// 用ajax发送post数据的时候记得先引入下json模块
// 注册
router.post('/register', controller.register)

// 校验用户cookie的有效性
router.use(controller.check)

router.get('/index', controller.index)

router.get('/list', controller.list)

router.get('/category', controller.category)

router.get('/categoryPage', controller.categoryPage)

router.post('/delete', controller.delete)

router.get('/zhen',controller.zhen)

// 设置上传的目录
var upload = multer({ dest: 'uploads/' })

// 新添图片文件上传
router.post('/upload', upload.single('img'),controller.upload)

router.get('/cha',controller.cha)

router.get('/gai',controller.gai)

router.post('/mimagai',controller.mimagai)

router.post('/avatar',upload.single('avatar'),controller.avatar)

router.post('/gaichen',upload.single('photo'),controller.gaichen)




module.exports = router